﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Commands.User.Commands.Order;
using ZLCMS.Business.Util;
using DotNet.Common.Command;

namespace ZLCMS.Web.SystemManage.Basics.Shop.Order
{
    public partial class OrderFinish : System.Web.UI.Page
    {
        protected FrameHelper _framePage;
        protected string _userAccount;
        string oid;
        protected void Page_Load(object sender, EventArgs e)
        {
            _userAccount = UserKit.GetUserAccountFailLogin();
            //初始化DWZ控件
            _framePage = new FrameHelper(this);


            if (!IsPostBack)
            {
                oid = Request["no"] == null ? "" : Request["no"];
                _oid.Text = oid;
            }
            else
            {
                oid = _oid.Text;
                Save();
            }
        }

        protected void Save()
        {
            ICommandResult<FinishOrderResult> res = new FinishOrderCommand().Execute(new FinishOrderParameter()
            {
                OrderNo = _oid.Text,
                UserAccount = _userAccount,
                Memo = tb_memo.Text
            });
            if (res.Error)
            {
                _framePage.Alert(new ReturnCode()
                {
                    statusCode = 300,
                    message = "操作失败!",
                    callbackType = "closeCurrent",
                    navTabId = "OrderDetail"
                });
            }
            else
            { 
            _framePage.Alert(new ReturnCode()
            {
                statusCode = 200,
                message = "操作成功!",
                callbackType = "closeCurrent",
                navTabId = "OrderDetail"
            });
            }

        }
    }
}
